package edu.polsl.bio.str.manager.command;

import edu.polsl.bio.str.common.messaging.StrDotsPayload;
import edu.polsl.bio.str.manager.error.BulkInsertErrorHandler;
import edu.polsl.bio.str.manager.logic.DotPlotBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * //todo class description
 * <p/>
 * Created on: Jul 22, 2011 2:52:22 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
public class DotPlotLoaderCommand extends BaseCommand<StrDotsPayload> {
  /**
   * slf4j Logger.
   */
  private static final Logger log = LoggerFactory.getLogger(DotPlotLoaderCommand.class.getName());

  private DotPlotBean dotPlotBean;

  private BulkInsertErrorHandler errorHandler;

  @Override
  protected void performLogic(StrDotsPayload context) {
    try {
      dotPlotBean.persistDotPlot(context);
    } catch (Exception e) {
      log.error("Error occurred during bulk insert", e);
      errorHandler.handleError(context, e);
    }
  }

  public void setDotPlotBean(DotPlotBean dotPlotBean) {
    this.dotPlotBean = dotPlotBean;
  }

  public void setErrorHandler(BulkInsertErrorHandler errorHandler) {
    this.errorHandler = errorHandler;
  }
}
